package com.java110.mall.shop.smo.impl;


import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import com.java110.dto.shop.ShopRangeRelDto;
import com.java110.intf.shop.IShopRangeRelInnerServiceSMO;
import com.java110.po.shop.ShopRangeRelPo;
import com.java110.mall.shop.dao.IShopRangeRelServiceDao;
import com.java110.utils.util.BeanConvertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 店铺经营范围关系内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopRangeRelInnerServiceSMOImpl extends BaseServiceSMO implements IShopRangeRelInnerServiceSMO {

    @Autowired
    private IShopRangeRelServiceDao shopRangeRelServiceDaoImpl;


    @Override
    public int saveShopRangeRel(@RequestBody ShopRangeRelPo shopRangeRelPo) {
        int saveFlag = 1;
        shopRangeRelServiceDaoImpl.saveShopRangeRelInfo(BeanConvertUtil.beanCovertMap(shopRangeRelPo));
        return saveFlag;
    }

     @Override
    public int updateShopRangeRel(@RequestBody  ShopRangeRelPo shopRangeRelPo) {
        int saveFlag = 1;
         shopRangeRelServiceDaoImpl.updateShopRangeRelInfo(BeanConvertUtil.beanCovertMap(shopRangeRelPo));
        return saveFlag;
    }

     @Override
    public int deleteShopRangeRel(@RequestBody  ShopRangeRelPo shopRangeRelPo) {
        int saveFlag = 1;
        shopRangeRelPo.setStatusCd("1");
        shopRangeRelServiceDaoImpl.updateShopRangeRelInfo(BeanConvertUtil.beanCovertMap(shopRangeRelPo));
        return saveFlag;
    }

    @Override
    public List<ShopRangeRelDto> queryShopRangeRels(@RequestBody  ShopRangeRelDto shopRangeRelDto) {

        //校验是否传了 分页信息

        int page = shopRangeRelDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopRangeRelDto.setPage((page - 1) * shopRangeRelDto.getRow());
        }

        List<ShopRangeRelDto> shopRangeRels = BeanConvertUtil.covertBeanList(shopRangeRelServiceDaoImpl.getShopRangeRelInfo(BeanConvertUtil.beanCovertMap(shopRangeRelDto)), ShopRangeRelDto.class);

        return shopRangeRels;
    }


    @Override
    public int queryShopRangeRelsCount(@RequestBody ShopRangeRelDto shopRangeRelDto) {
        return shopRangeRelServiceDaoImpl.queryShopRangeRelsCount(BeanConvertUtil.beanCovertMap(shopRangeRelDto));    }

    public IShopRangeRelServiceDao getShopRangeRelServiceDaoImpl() {
        return shopRangeRelServiceDaoImpl;
    }

    public void setShopRangeRelServiceDaoImpl(IShopRangeRelServiceDao shopRangeRelServiceDaoImpl) {
        this.shopRangeRelServiceDaoImpl = shopRangeRelServiceDaoImpl;
    }
}
